<?php

declare(strict_types=1);

namespace App\CustHub\Listener;

use App\CustHub\Event\UserLeftRoomEvent;
use App\CustHub\Service\RoomInviteService;
use Hyperf\Event\Annotation\Listener;
use Hyperf\Event\Contract\ListenerInterface;
use Psr\Container\ContainerInterface;
use function Hyperf\Coroutine\co;

#[Listener]
class UserLeftRoomListener implements ListenerInterface
{

    protected $container;

    public function __construct(ContainerInterface $container)
    {
        $this->container = $container;
    }

    public function listen(): array
    {
        return [
            UserLeftRoomEvent::class
        ];
    }


    public function process(object $event): void
    {
        $roomWxid = $event->roomWxid;
        co(function () use ($roomWxid){
            //处理替补群
            $this->container->get(RoomInviteService::class)->processSubstituteRoom($roomWxid);
        });
    }

}